<?php

#    Document   : dashboard
#    Created on : May 8, 2011, 12:51:54 AM
#    Author     : ClarkT AKA FalleN
#    Company    : Amodity
#    Web        : http://www.amodity.com
#    Copyright  : 2011
/**

 * @property CI_Loader $load

 * @property CI_Form_validation $form_validation

 * @property CI_Input $input

 * @property CI_Email $email

 * @property CI_DB_active_record $db

 * @property CI_DB_forge $dbforge

 *  @property CI_Session $session

 * @property CI_FTP $ftp

 */

class Dashboard_model extends CI_Model {

    function userimages($username) {
        //get db results
        $this->db->where('author', $username);
        $query = $this->db->get('images');
        //verify results exsist and return
        if ($query->num_rows() > 0) {
            $row = $query->result_array();
            return $row;
        } else {
            return false;
        }
    }

    function total($username) {
        $this->db->where('author', $username);
        $query = $this->db->get('images');
        return $query->num_rows();
    }
    
    function analytics() {
        $this->load->library('ga_api');
        $config['id'] = config_item('id');
        $config['email'] = config_item('email');
        $config['password'] = config_item('password');
        
        $this->ga_api->initialize($config);
        
        return $data = $this->ga_api->dimension('source')->metric('visits, pageviews')->get_object();
        
    }

}

?>